//
//  GZViewController.m
//  GZSegmentBar
//
//  Created by GR on 01/10/2018.
//  Copyright (c) 2018 GR. All rights reserved.
//

#import "GZViewController.h"
#import "GZSegmentBar.h"
#import <GRFMBaseLib/UIView+XMGLayout.h>
#import "GZSegmentContainerViewController.h"
@implementation GZSegmentBarModel
@synthesize content;
@end

@interface GZViewController ()

@end

@implementation GZViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	
    NSMutableArray *segmentModels = [NSMutableArray arrayWithCapacity:0];
    for (NSString *string in @[ @"发现", @"广播",@"探索地理", @"科学", @"哲学", @"地理", @"历史" ]) {
        GZSegmentBarModel *m = [[GZSegmentBarModel alloc] init];
        m.content = string;
        [segmentModels addObject:m];
    }

    UIViewController *vc1 = [[UIViewController alloc] init];
    vc1.view.backgroundColor = [UIColor greenColor];

    UIViewController *vc2 = [[UIViewController alloc] init];
    vc2.view.backgroundColor = [UIColor redColor];

    UIViewController *vc3 = [[UIViewController alloc] init];
    vc3.view.backgroundColor = [UIColor yellowColor];

    UIViewController *vc4 = [[UIViewController alloc] init];
    vc4.view.backgroundColor = [UIColor brownColor];

    UIViewController *vc5 = [[UIViewController alloc] init];
    vc5.view.backgroundColor = [UIColor cyanColor];

    UIViewController *vc6 = [[UIViewController alloc] init];
    vc6.view.backgroundColor = [UIColor blueColor];

    UIViewController *vc7 = [[UIViewController alloc] init];
    vc7.view.backgroundColor = [UIColor blackColor];


    
    GZSegmentContainerViewController *containerVc = [[GZSegmentContainerViewController alloc] init];
    //    GZSegmentBar *segmentBar = [[GZSegmentBar alloc] init];
    //    segmentBar.frame = CGRectMake(0, 20, self.view.width, 50);
    //    segmentBar.delegate = containerVc;
    //    [self.view addSubview:segmentBar];
//    containerVc.segmentBar = segmentBar;

//    containerVc.view.frame = CGRectMake(0, CGRectGetMaxY(segmentBar.frame), self.view.width, self.view.height - CGRectGetMaxY(segmentBar.frame));
    containerVc.view.frame = self.view.bounds;
    
    [containerVc setItems:segmentModels childViewControllers:@[ vc1, vc2, vc3, vc4, vc5, vc6, vc7 ]];

    [self.view addSubview:containerVc.view];
    [self addChildViewController:containerVc];
}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//    NSMutableArray *segmentModels = [NSMutableArray arrayWithCapacity:0];
//    for (NSString *string in @[ @"发现", @"广播",@"探索地理", @"科学", @"哲学", @"地理", @"历史" ]) {
//        GZSegmentBarModel *m = [[GZSegmentBarModel alloc] init];
//        m.content = string;
//        [segmentModels addObject:m];
//    }
//    
//    UIViewController *vc1 = [[UIViewController alloc] init];
//    vc1.view.backgroundColor = [UIColor greenColor];
//    
//    UIViewController *vc2 = [[UIViewController alloc] init];
//    vc2.view.backgroundColor = [UIColor redColor];
//    
//    UIViewController *vc3 = [[UIViewController alloc] init];
//    vc3.view.backgroundColor = [UIColor yellowColor];
//    
//    UIViewController *vc4 = [[UIViewController alloc] init];
//    vc4.view.backgroundColor = [UIColor brownColor];
//    
//    UIViewController *vc5 = [[UIViewController alloc] init];
//    vc5.view.backgroundColor = [UIColor cyanColor];
//    
//    UIViewController *vc6 = [[UIViewController alloc] init];
//    vc6.view.backgroundColor = [UIColor blueColor];
//    
//    UIViewController *vc7 = [[UIViewController alloc] init];
//    vc7.view.backgroundColor = [UIColor blackColor];
//    
//    GZSegmentContainerViewController *containerVc = [[GZSegmentContainerViewController alloc] init];
//    containerVc.view.frame = self.view.frame;
//    [containerVc setItems:segmentModels childViewControllers:@[ vc1, vc2, vc3, vc4, vc5, vc6, vc7 ]];
//    
//    [self.navigationController pushViewController:containerVc animated:YES];
    
}


@end
